/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.srcptit.trainning.giangnd.btvn2;

import java.util.Scanner;

/**
 *
 * @author GIANG
 */
public class IO {
    public static int Nhap_Int() {
        int a=0;
        int t=0;
        while(t==0){
            t=1;
            try{
                Scanner sc = new Scanner(System.in);
                System.out.println("Nhap int");
                a=sc.nextInt();
            }catch (Exception e){
                System.out.println("Khong phai kieu int. Nhap lai!");
                t=0;
            }
        }
        return a;
    }
    public static String Nhap_String() {
        String a="";
        int t=0;
        while(t==0){
            t=1;
            try{
                Scanner sc = new Scanner(System.in);
                System.out.println("Nhap String");
                a=sc.nextLine();
            } catch (Exception e) {
                System.out.println("Khong phai kieu String. Nhap lai!");
                t=0;
            }
        }
        return a;
    }
    public static float Nhap_Float() {
        float a=0;
        int t=0;
        while(t==0){
            t=1;
            try {
                Scanner sc = new Scanner(System.in);
                System.out.println("Nhap Float");
                a=sc.nextFloat();
            } catch(Exception e) {
                System.out.println("Khong phai kieu Float. Nhap lai!");
                t=0;
            }
        }
        return a;
    }
    public static double Nhap_Double() {
        double a=0;
        int t=0;
        while(t==0) {
            t=1;
            try{
                Scanner sc = new Scanner(System.in);
                System.out.println("Nhap double");
                a=sc.nextDouble();
            } catch(Exception e) {
                System.out.println("Khong phai kieu double. Nhap lai!");
                t=0;
            }
        }
        return a;
    }
    public static void main(String[] args) {
        Nhap_Int();
        Nhap_Float();
        Nhap_String();
        Nhap_Double();
    }
}
